﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WinSort.Ctrl
{
    public partial class View : UserControl
    {
        Color lineColor = Color.DeepSkyBlue;
        Pen linePen;

        public View()
        {
            InitializeComponent();
            linePen = new Pen(lineColor, 2);
        }

        public Label Label { get { return this.label1; } }
        
        public void Draw(IEnumerable<int> source)
        {
            try {
                var g = this.panel1.CreateGraphics();
                var x = 2;
                var y = this.Height;
                var pading = 1;
                var i = 0;
                foreach (var item in source) {
                    g.DrawLine(new Pen(this.BackColor, 1), x, y, x, 0);
                    g.DrawLine(linePen, x, y, x, y - item);
                    x += pading;
                    i += 1;
                }
            } catch (Exception) {
                return;
            }
            

            System.Threading.Thread.Sleep(100);
        }
    }
}
